/**
 * Funkcje do kalendarza z rozkladem zajec
 * 
 */
 function getDataJson (url, param, callback){
		  var temp;
		  $.ajax({
	  		  type: 'POST',
	  		  url: url,
	  		  // data: param,
	  		  async: false,
	  		  dataType : 'json',
	  		  success: function(data) {
	  			 temp = data;  
	  		  }
		  });
		  return temp;
	  }

function calendar() { 
	var _title;
	var _start; 
	var _end; 
	var _allDay; 
	var date = new Date();
	var d = date.getDate();
	var m = date.getMonth();
	var y = date.getFullYear();
	var  data = getDataJson('/dydack/public/technical/test/get','aa','aa');
/*
 * var task = $("#task"); var semester = $("#semester"); var subject =
 * $("#subject"); var numberHour = $("#numberHour"); var numberWeek =
 * $("#numberWeek"); var dimensionWeek = $("#dimensionWeek"); var typeCourse =
 * $("#typeCourse"); var typeCredit = $("#typeCredit"); var user = $("#user");
 * var speciality = $("#speciality"); var year = $("#year"); var
 * dimensionSemester = $("#dimensionSemester"); var hourYear = $("#hourYear");
 * var hourSemester = $("#hourSemester");
 * 
 * $("#acceptOrder").click(function(){ var validator =
 * $("#form").validationEngine('validate'); if(validator){ $.ajax({ url:
 * "kalendarz.php", type: "POST", data: "task=task", // tu paramtery dodać
 * error: function() {alert('eerrrr');}, success: function() {
 * 
 * calendar.fullCalendar('renderEvent', { title: task.val(), start: _start, end:
 * _end, allDay: _allDay, url: 'http://google.com/'
 *  }, true
 *  );
 * 
 *  $( "#order-form").dialog( "close" );
 * setTimeout('document.getElementById(\'form\').reset()');
 * 
 *  }
 * 
 * });
 * 
 *  } return false; });
 * 
 * //$("#zendForm").validationEngine({promptPosition : "centerRight",scroll :
 * true}); $( "#dialog:ui-dialog" ).dialog( "destroy"); $( "#order-form"
 * ).dialog({ autoOpen: false, height: 600, width: 380, modal: true, buttons: {
 *  }, close: function() { }
 * 
 * 
 * }); $("#cancelOrder").click(function() { $("#order-form").dialog( "close" );
 * 
 * });
 */
	 

	
	var calendar = $('#calendar').fullCalendar({ 
	      header: { 
		    left: 'prev,next, today', 
		    center: 'title', 
		    right: 'month,basicDay' ,
		

	      }, 
	      selectable: true, 
	      selectHelper: true, 
	      select: function(start, end, allDay) { 
					var title = prompt('Event Title:');
					if (title) {
						calendar.fullCalendar('renderEvent',
							{
								title: title,
								start: start,
								end: end,
								allDay: allDay

							},
							true // make the event "stick"
						);
						
						 $.ajax({
					  		  type: 'POST',
					  		  url: '/dydack/public/technical/test/add',
					  		  data: 'title=zabij',
					  		  async: false,
					  		  dataType : 'json',
		                        success: function (resp) {
		                            calendar.fullCalendar('refetchEvents');
		                        }
		                    });		
					}


		//	_title = title;
		  //  _start = start; 
		   // _end = end; 
		   // _allDay = allDay; 
		    calendar.fullCalendar('unselect'); 
		}, 
		editable: true, 
		events: [
					{					
						title: 'value',
						start: new Date(y, m, 1)
					}],
		
		
		
		
		
		timeFormat: 'H(:mm)', 
		axisFormat: 'H(:mm)', 
		// defaultView : 'agendaWeek',
		firstDay: 1,
		dayclick: formAddSchedule()
		
	  }); 
}